package com.ruoyi.web.controller.comprehensive;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.utils.pengjie.SnowflakeIdUtils;
import com.ruoyi.comprehensive.dto.VentilationDto;
import com.ruoyi.comprehensive.dto.VentilationExamineDto;
import com.ruoyi.comprehensive.vo.PreventionVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.comprehensive.domain.VentilationPreventionExamine;
import com.ruoyi.comprehensive.service.IVentilationPreventionExamineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通风审核Controller
 * 
 * @author hcc
 * @date 2023-12-13
 */
@RestController
@RequestMapping("/comprehensive/examine")
public class VentilationPreventionExamineController extends BaseController
{
    @Autowired
    private IVentilationPreventionExamineService ventilationPreventionExamineService;

    /**
     * 查询通风审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:list')")
    @GetMapping("/list")
    public TableDataInfo list(VentilationPreventionExamine ventilationPreventionExamine)
    {
        startPage();
        List<VentilationPreventionExamine> list = ventilationPreventionExamineService.selectVentilationPreventionExamineList(ventilationPreventionExamine);
        return getDataTable(list);
    }

    /**
     * 导出通风审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:export')")
    @Log(title = "通风审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VentilationPreventionExamine ventilationPreventionExamine)
    {
        List<VentilationPreventionExamine> list = ventilationPreventionExamineService.selectVentilationPreventionExamineList(ventilationPreventionExamine);
        ExcelUtil<VentilationPreventionExamine> util = new ExcelUtil<VentilationPreventionExamine>(VentilationPreventionExamine.class);
        util.exportExcel(response, list, "通风审核数据");
    }

    /**
     * 获取通风审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ventilationPreventionExamineService.selectVentilationPreventionExamineById(id));
    }

    /**
     * 新增通风审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:add')")
    @Log(title = "通风审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VentilationPreventionExamine ventilationPreventionExamine)
    {
        return toAjax(ventilationPreventionExamineService.insertVentilationPreventionExamine(ventilationPreventionExamine));
    }

    /**
     * 修改通风审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:edit')")
    @Log(title = "通风审核", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody VentilationPreventionExamine ventilationPreventionExamine)
    {
        return toAjax(ventilationPreventionExamineService.updateVentilationPreventionExamine(ventilationPreventionExamine));
    }

    /**
     * 删除通风审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:remove')")
    @Log(title = "通风审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ventilationPreventionExamineService.deleteVentilationPreventionExamineByIds(ids));
    }
    /**
     * 查询通风审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:examine:list')")
    @GetMapping("/getList")
    public TableDataInfo getList(PreventionVo vo) {
        startPage();
        PageInfo<VentilationExamineDto> list = ventilationPreventionExamineService.getVentilationPreventionExamineList(vo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list.getList());
        rspData.setTotal(list.getTotal());
        return rspData;
    }
}
